package mrHunter.server;
import mrHunter.lib.Graph;
import mrHunter.lib.InputType.array.Input4.Input;
import mrHunter.lib.OutputType.array.Output4.Output;
import mrHunter.puzzles.array.Puzzle4;
public class MR {
    private Input input1,input2,input3,input4,input5,input6;
    private Output output1,output2,output3,output4,output5,output6;
    public MR(){
        input1=new Input();input2=new Input();input3=new Input();input4=new Input();input5=new Input();input6=new Input();
        output1=new Output();output2=new Output();output3=new Output();output4=new Output();output5=new Output();output6=new Output();
    }
    public boolean userMR(String[] inputs, int sourceInputNum, int followupInputNum){
                   switch (sourceInputNum){
                       case 3:input3=stringToInput(inputs[2]);
                       case 2:input2=stringToInput(inputs[1]);
                       case 1:input1=stringToInput(inputs[0]);
                   default:break;
               }
/*Assign values to inputs whose value need to be assigned here...*/
int len = input1.A.length;
input2.A = new int[len];
for(int i = 0; i < len; i++){
	input2.A[i] = input1.A[len - i - 1];
}
        getOutput(sourceInputNum,followupInputNum);
/*The outputs of corresponding inputs have been generated, you can describe relations here*/
if(output2.c + output1.c <= len * (len - 1)/2)
  return true;
else
  return false;
    }
    public void getOutput(int sourceInputNum,int followupInputNum) {
            int num=sourceInputNum+followupInputNum;
            switch (num){
                case 6: output6=inputToOutput(input6);
                case 5: output5=inputToOutput(input5);
                case 4: output4=inputToOutput(input4);
                case 3: output3=inputToOutput(input3);
                case 2: output2=inputToOutput(input2);
                case 1: output1=inputToOutput(input1);
                default:break;
            }
    }
    public Input stringToInput(String s){
        Input input=new Input();
        String[] inputArray=s.split(" ");

                input.A=new int[inputArray.length];
                for(int i=0;i<inputArray.length;i++)
                    input.A[i]=Integer.parseInt(inputArray[i]);
        return input;
    }
    public Output inputToOutput(Input input){
        Output output=new Output();
       String res="";
               for(int i=0;i<input.A.length;i++){
                   res+=String.valueOf(input.A[i]);
                   if(i!=input.A.length-1)
                       res+=" ";
               }
               Puzzle4 puzzle4=new Puzzle4();
               String tempRes=puzzle4.inverseNumber(res);

               output.c=Integer.parseInt(tempRes);
        return output;
    }
}
